import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.

    // 这只是语法层面
    // 真正牛逼的是：webpack，webpack 内部在构建的时候会把这种包单独解析成一个 js 文件
    // 注意：懒加载的路由太多的话会导致打包性能下降
    // 600+ 懒加载路由，导致打包直接打不动了
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
